package demo7.teht;


import java.awt.Color;
import java.util.Random;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Pasi
 */
public class T5_Ball {
    private int x;
    private int dx;
    private int y;
    private int dy;
    private int size;
    private Color color;
    private int maxX, maxY;
    
    public T5_Ball(int maxX, int maxY){
        Random rand = new Random();
        this.x = rand.nextInt(maxX);
        this.y = rand.nextInt(maxY);
        this.size = 25;
        this.dx = rand.nextInt(6)-3;
        if (this.dx == 0) this.dx = 3;
        this.dy = rand.nextInt(6)-3;
        if (this.dy == 0) this.dy = 3;
        this.color = new Color(rand.nextInt(255),rand.nextInt(255),rand.nextInt(255));
        
        this.maxX = maxX;
        this.maxY = maxY;
    }
    
    public void move() {
        this.x += dx;
        this.y += dy;
        
        if (this.x > maxX || this.x < 0) {
            dx*=-1;
        }
        if (this.y > maxY || this.y < 0) {
            dy*=-1;
        }
    }
    
    public int getX() { return this.x; }
    public int getY() { return this.y; }
    public int getSize() { return this.size; }
    public Color getColor() { return this.color; }
    
}
